//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
  },
  onLoad: function () {
    this.getSetting();
  },
  onShow() {

  },
  onReShow(){
    console.log("----onReShow---")
  },


  // 获取用户配置信息
  getSetting: function () {
    wx.getSetting({
      success: (res) => {
        debugger;
        wx.shareData.authSetting = res.authSetting;
        if (res.authSetting['scope.userInfo']) {
          this.getUserInfo();
        } else {
          this.navToLogin();
        }
      }
    });

  },


  // 获取用户信息
  getUserInfo: function () {
    wx.getUserInfo({
      success: (res) => {
        debugger;
        // 可以将 res 发送给后台解码出 unionId
        // this.globalData.userInfo = res.userInfo;
        if (wx.collectLoginData(res)) {
          wx.shareInst.Api.login();
        }

      }
    });
  },


// 跳转到授权页面
  navToLogin: function () {
    wx.navigateTo({
      url: '/pages/login/login',
    });
  },


  submitHandle: function (event){
    debugger
    let detail = event.detail;
    let formId = detail.formId;
    wx.shareData.formId = formId;
    console.log("formId:",formId);
  },


})
